package com.zbkj.admin.controller.brand;

import com.zbkj.common.annotation.LogControllerAnnotation;
import com.zbkj.common.enums.MethodType;
import com.zbkj.common.model.page.PageLink;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.*;
import com.zbkj.common.request.page.PageLinkRequest;
import com.zbkj.common.response.ArticleInfoResponse;
import com.zbkj.common.response.ArticleResponse;
import com.zbkj.common.response.BrandNameResponse;
import com.zbkj.common.response.BrandResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.ArticleService;
import com.zbkj.service.service.BrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 品牌商管理表 前端控制器
 +----------------------------------------------------------------------
 */
@Slf4j
@RestController
@RequestMapping("api/admin/brand/basic")
@Api(tags = "品牌商管理")
public class BrandBasicController {

    @Autowired
    private BrandService brandService;

//    @PreAuthorize("hasAuthority('brand:article:list')")
    @ApiOperation(value = "品牌商分页列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "品牌商名称", dataType = "string"),
    })
    public CommonResult<CommonPage<BrandResponse>> getList(@Validated BrandSearchRequest request,
                                                           @Validated PageParamRequest pageParamRequest) {
        return CommonResult.success(CommonPage.restPage(brandService.getAdminListBrand(request, pageParamRequest)));
    }

    @ApiOperation(value = "根据推广链接获取品牌商名称")
    @RequestMapping(value = "/name", method = RequestMethod.POST)
    public CommonResult<BrandNameResponse> name(@RequestBody @Validated BrandNameSearchRequest request){
        return CommonResult.success(brandService.getName(request));
    }

}



